#include "Timer.h"

namespace varayoc
{

   namespace vigilance
   {

      namespace util
      {

         Timer::Timer() :
               m_isStart(False), m_checkOut(False)
         {
         }

         Timer::~Timer()
         {
         }

         Timer_ptr Timer::create()
         {
            return Timer_ptr(new Timer());
         }

         Void Timer::startTimer()
         {
            if (!m_isStart)
            {
               start();
               release(False);
            }
         }

         UInt32 Timer::run()
         {
            m_isStart = True;
            m_checkOut = False;
            m_intervalBeatWait.wait(m_interval);
            m_checkOut = True;
            return 0;
         }

         Bool Timer::checkTimer()
         {
            Bool ret = m_checkOut;
            if (m_checkOut)
            {
               stopTimer();
            }
            return ret;
         }

         Void Timer::stopTimer()
         {
            m_isStart = False;
            m_checkOut = False;
         }

      }

   }

}
